/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.web.command.component.metadata;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.inspur.edp.web.command.component.serializer.CommandItemDeSerializer;
import com.inspur.edp.web.command.component.serializer.CommandItemSerializer;
import com.inspur.edp.web.command.component.serializer.OldCommandItemSerializer;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能描述:
 *
 * @ClassName: BranchCommandItem
 * @Author: Fynn Qi
 * @Date: 2020/1/1 9:14
 * @Version: V1.0
 */
public class BranchCommandItem implements CommandItem {
//    private String id;
//    private String code;
//    private String name;
//    private ConditionType conditionType;
//    private String express;
//    private final List<CommandItem> items;

    @JsonProperty("Id")
    private String id;

    @JsonProperty("Code")
    private String code;

    @JsonProperty("Name")
    private String name;

    @JsonProperty("ConditionType")
    private ConditionType conditionType;

    @JsonProperty("Express")
    private String express;

    @JsonProperty("Items")
    @JsonSerialize(using = OldCommandItemSerializer.class)
    @JsonDeserialize(using = CommandItemDeSerializer.class)
    private List<CommandItem> items;

    @Override
    public CommandItemType getItemType() {
        return CommandItemType.Branch;
    }

    @Override
    public String getItemName() {
        return this.name;
    }

    @Override
    public String getItemId() {
        return this.id;
    }

    public BranchCommandItem() {
        this.items = new ArrayList<>();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ConditionType getConditionType() {
        return conditionType;
    }

    public void setConditionType(ConditionType conditionType) {
        this.conditionType = conditionType;
    }

    public String getExpress() {
        return express;
    }

    public void setExpress(String express) {
        this.express = express;
    }

    public List<CommandItem> getItems() {
        return items;
    }
}
